Giter Club home page Giter Club logo

fake2db's People

Contributors

akash0x53 avatar alexandershov avatar bhrgu avatar confusingstraw avatar emirozer avatar jenschelkopf avatar karlwithak avatar mauricioabreu avatar shelt avatar thomasdziedzic-pd avatar toutoudnf avatar trinaldi avatar tunavargi avatar xuefeng-zhu avatar ycyuxin avatar zhmin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fake2db's Issues

Companies Data Not Working?

Hi. I tried to load up a database with some test data last night:

$ fake2db --rows 1000000 --db postgresql --name test-things

For the most part this seems to have worked, every table except "companies" has exactly 1,000,000 records. Companies, on the other hand, has zero. Any idea why? I don't have the command output any more, but there weren't any errors reported.

--database option

When using against postgresql the database name is expected to be the same as the --username

AttributeError: 'NoneType' object has no attribute 'execute'

Cool idea; wanted to play with this.

OSX 10.9.5
MySQL 5.5.38
Python 2.7.5

Installed http://dev.mysql.com/downloads/connector/python/

Opened new terminal (iTerm2) session

Ran
$ fake2db --rows 200 --db mysql

Got:

Traceback (most recent call last):
  File "/usr/local/bin/fake2db", line 8, in <module>
    load_entry_point('fake2db==0.1.5', 'console_scripts', 'fake2db')()
  File "/Library/Python/2.7/site-packages/fake2db/fake2db.py", line 106, in main
    fake_mysql_handler.fake2db_mysql_initiator(host, port, int(args.rows))
  File "/Library/Python/2.7/site-packages/fake2db/mysql_handler.py", line 42, in fake2db_mysql_initiator
    cursor.execute(tables[key])
AttributeError: 'NoneType' object has no attribute 'execute'

Any thoughts? Thanks!

Populate an existing database + schema?

Hey there – is there any way we could run this against an existing database (with a flag or something is fine) and not get errors? We'd like to add this to our migrations in our dev environments, but we end up having to create a new database, then import it into the primary db.

We'd be happy to make adjustments in a PR if you want to outline the easiest / best way to do so. Thanks :)

Not sure how to start with.

Hi,
I've installed fake2db successfully in ubuntu 14.04 and still, i'm unable to run cli commands as shown in readme.

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

fake2db --rows 100 --db postgresql --name testdb
File "", line 1
fake2db --rows 100 --db postgresql --name testdb
^
SyntaxError: invalid syntax

database already exists

I inserted 10000 to the db named fake. Then I want to insert another 10000. But error happened.

fake2db --rows 10000 --db postgresql --name fake --username postgres
2019-03-18 09:55:19,907 www Rows argument : 20000
2019-03-18 09:55:20,036 www database "fake" already exists

Traceback (most recent call last):
File "/home/www/pyenv/aws/bin/fake2db", line 11, in
sys.exit(main())
File "/home/www/pyenv/aws/local/lib/python2.7/site-packages/fake2db/fake2db.py", line 167, in main
number_of_rows=args.rows, name=args.name, custom=custom)
File "/home/www/pyenv/aws/local/lib/python2.7/site-packages/fake2db/postgresql_handler.py", line 18, in fake2db_initiator
cursor, conn = self.database_caller_creator(number_of_rows, **connection_kwargs)
File "/home/www/pyenv/aws/local/lib/python2.7/site-packages/fake2db/postgresql_handler.py", line 46, in database_caller_creator
cur.execute('CREATE DATABASE %s;' % dbname)
psycopg2.ProgrammingError: database "fake" already exists

Thanks for your great work.

Missing tags

Can you create the tag with the last version? Thanks.

Python socket package throws error in fake2db_logger under helpers.py

$ fake2db --help
Traceback (most recent call last):
  File "/usr/local/bin/fake2db", line 9, in <module>
    load_entry_point('fake2db==0.2.2', 'console_scripts', 'fake2db')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 357, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2394, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2108, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Library/Python/2.7/site-packages/fake2db/fake2db.py", line 7, in <module>
    logger, extra_information = fake2db_logger()
  File "/Library/Python/2.7/site-packages/fake2db/helpers.py", line 13, in fake2db_logger
    local_ip = socket.gethostbyname(socket.gethostname())
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

I don't think it's an internet issue, as I am connecting to the ip of a local vm. What are your thought?

Allow multiple columns with same faker key OR allow column naming

I found myself needing to do the following to replicate a table structure:

fake2db --rows 1500 --db mysql --name=test_speed --username root --password secret --custom date_time_this_year random_digit_not_null random_digit_not_null uuid4 word boolean boolean boolean random_number random_number word last_name word word word word last_name year

Then I found out that I couldn't use duplicate faker keys for my columns, so using random_digit_not_null twice is not possible.

I wrote some code in the mysql handler to append keys to the columns in order to allow duplicates (see this commit denitsa-md@73df919)

I do think the mysql_handler is probably not the best place for this -> the unique columns should somehow be formatted further up and passed to all handlers. But it's the first time I'm touching python so I just hacked it a bit for my purposes.

Then the command above would result in a table structure like this:

image

Would be nice if something like this was supported out of the box for all database engines. Or perhaps even better, the option to name the columns in addition to providing the faker keys. This would alleviate the issue altogether.

Missing faker_options_container

SUMMARY: Followed README, attempted to run fake2db.py but encounter missing dependencies. The following replicates my steps to include confirmation of dependencies:

ERROR:
_ Traceback (most recent call last):
File "fake2db.py", line 6, in
from .custom import faker_options_container
ValueError: Attempted relative import in non-package
_

STEPS:

# pip install fake2db
Requirement already satisfied: fake2db in /Users/jason/Documents/Scripts/fake2db
Requirement already satisfied: fake-factory>=0.5.3 in /usr/local/lib/python2.7/site-packages (from fake2db)

# pip install psycopg2
Requirement already satisfied: psycopg2 in /usr/local/lib/python2.7/site-packages

# cd /Users/jason/Documents/Scripts/fake2db
*# ls
LICENSE docs fake2db.egg-info setup.py
README.md fake2db requirements.txt

# pip install -r requirements.txt
Obtaining file:///Users/jason/Documents/Scripts/fake2db (from -r requirements.txt (line 3))
Requirement already satisfied: fake-factory>=0.5.3 in /usr/local/lib/python2.7/site-packages (from fake2db==0.5.2->-r requirements.txt (line 3))
Installing collected packages: fake2db
Found existing installation: fake2db 0.5.2
Uninstalling fake2db-0.5.2:
Successfully uninstalled fake2db-0.5.2
Running setup.py develop for fake2db
Successfully installed fake2db

# cd fake2db
# ls
init.py custom.py mongodb_handler.py redis_handler.py
base_handler.py fake2db.py mysql_handler.py sqlite_handler.py
couchdb_handler.py helpers.py postgresql_handler.py

# python fake2db.py --db postgresql --host 127.0.0.1 --port 5432 --password fakepassword --username postgres --name TESTDB --rows 100 --custom address

Traceback (most recent call last):
File "fake2db.py", line 6, in
from .custom import faker_options_container
ValueError: Attempted relative import in non-package

Error when running cli

I tried with and without a virtualenv for dependency isolation, using the following command:

fake2db --db postgresql --host 0.0.0.0 --port 5632 --password password --username user --rows 10 --name mydb

Which gave me:

File "/usr/local/bin/fake2db", line 7, in <module>
    from fake2db.fake2db import main
  File "/usr/local/lib/python3.5/site-packages/fake2db/fake2db.py", line 6, in <module>
    from custom import faker_options_container
ImportError: No module named 'custom'

But the custom.py file exists, it's just not finding it. Installed using pip 9.0.1 and python 2.7.10.

sudo seems to work to bypass the error. Not sure why it needs it, but this is probably unrelated to the specific package, so I'll close this.

Allow faster data loading.

I would like to create a table with a million rows or more to stress test a service I am evaluating.

Using a server hosted by aws (rds mysql 5.6), I'm currently using no cpu on my macbook so it is definitely network bound.

I'm able to load about 3000 rows per 5 minutes.
This speed is really slow when you would like to generate a very large table (e.g. many millions of rows)

Some possible suggestions:

  1. bulk insert
  2. save to a csv, and then call a sql command to load from csv
  3. create a pool of connections and insert through each connection

How to get auto-increment ID and specify custom column names?

Hi,

I just ran this command:

$ fake2db --rows 3 --db sqlite --custom name date country

And the result that I got:

db

I have 2 questions here:

  1. How do I get auto-increment ID? For example, Francis get id 1 and Robert get id 3?
  2. How do I rename the custom column names? For example, full_name instead of name and birth_date instead of date.

Thank you in advance for your help. This project is very cool and helpful. πŸ™‚

MySql connector is always required

I'm attempting to use PostgreSQL and I get an error saying I need the MySql Connector.

# fake2db --rows 1500 --db postgresql
2014-12-18 13:49:03,846 109.116.104.115 squarejaw    MySql Connector/Python not found on sys, you need to get it : http://dev.mysql.com/downloads/connector/python/

Support different DB backends

In the readme you write:

  • Add more DB types

have you thought about using SQLAlchemy? That would save you from adding more code just to support another DB.

Cheers,
Jan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.