Mailing List Archive

Faker package
I'm trying to use the faker package to generate data to load in a sample
postgres database so I can learn how to use tksheet and psycopg2.

The 8.8.1 documentation shows output on a root shell prompt (#), not a
python prompt (>>>). It also has a description of using faker from 'the
command line', which I assume is the python shell, and I can't get it to
work. I suppose that I can generate one name, address, etc. at a time and
them copy and concatenate them into table data, but I thought that the faker
package would do this all for me.

Is there a tool that will let me generate the equivalent of a database row
worth of data? That is, a set of strings of different types that can then be
inserted into the testing database?

Rich


--
https://mail.python.org/mailman/listinfo/python-list
Re: Faker package [ In reply to ]
On 6/18/2021 6:24 PM, Rich Shepard wrote:
> I'm trying to use the faker package to generate data to load in a sample
> postgres database so I can learn how to use tksheet and psycopg2.
>
> The 8.8.1 documentation shows output on a root shell prompt (#), not a
> python prompt (>>>). It also has a description of using faker from 'the
> command line', which I assume is the python shell, and I can't get it to
> work. I suppose that I can generate one name, address, etc. at a time and
> them copy and concatenate them into table data, but I thought that the
> faker
> package would do this all for me.
>
> Is there a tool that will let me generate the equivalent of a database row
> worth of data? That is, a set of strings of different types that can
> then be
> inserted into the testing database?

I would try using the 'given' function/decorator of hypothesis (on pypi)
to generate random data that conforms to whatever specification.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list
Re: Faker package [ In reply to ]
On Fri, 18 Jun 2021, Terry Reedy wrote:

> I would try using the 'given' function/decorator of hypothesis (on pypi)
> to generate random data that conforms to whatever specification.

Thank you, Terry. I'll do that.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list
Re: Faker package [ In reply to ]
On 2021-06-18 23:24, Rich Shepard wrote:
> I'm trying to use the faker package to generate data to load in a sample
> postgres database so I can learn how to use tksheet and psycopg2.
>
> The 8.8.1 documentation shows output on a root shell prompt (#), not a
> python prompt (>>>). It also has a description of using faker from 'the
> command line', which I assume is the python shell, and I can't get it to
> work. I suppose that I can generate one name, address, etc. at a time and
> them copy and concatenate them into table data, but I thought that the faker
> package would do this all for me.
>
When it says "command line" it means the operating system's command
line. If it's the Python shell , it'll say "Python shell" or "Python prompt.

The "root shell prompt (#)" suggests to me that it's Linux, so if
you're using Windows you'll need to use the equivalent for Windows.

> Is there a tool that will let me generate the equivalent of a database row
> worth of data? That is, a set of strings of different types that can then be
> inserted into the testing database?
>
--
https://mail.python.org/mailman/listinfo/python-list
Re: Faker package [ In reply to ]
On Sat, 19 Jun 2021, MRAB wrote:

> When it says "command line" it means the operating system's command line. If
> it's the Python shell , it'll say "Python shell" or "Python prompt.

MRAB,

The root shell's (#) what I assumed. User shells (in bash, anyway) have $ as
the prompt.

Regardless,

$ faker -o temp.out faker.names()
-bash: syntax error near unexpected token `('
[rshepard@salmo ~]$ faker -o temp.out faker.names
Traceback (most recent call last):
File "/usr/bin/faker", line 8, in <module>
sys.exit(execute_from_command_line())
File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 264, in execute_from_command_line
command.execute()
File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 246, in execute
includes=arguments.include,
File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 67, in print_doc
provider_or_field], includes=includes)
File "/usr/lib64/python3.7/site-packages/faker/proxy.py", line 63, in __init__
**config)
File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 56, in create
prov_cls, lang_found = cls._get_provider_class(prov_name, locale)
File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 68, in _get_provider_class
provider_class = cls._find_provider_class(provider, locale)
File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 90, in _find_provider_class
provider_module = import_module(provider_path)
File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'faker.names'
[rshepard@salmo ~]$

It does not work from the bash command line as a user or as root.

> The "root shell prompt (#)" suggests to me that it's Linux, so if you're
> using Windows you'll need to use the equivalent for Windows.

I don't do windows; defenestrated 24 years ago.

Rich
--
https://mail.python.org/mailman/listinfo/python-list
Re: Faker package [ In reply to ]
On 2021-06-19 02:51, Rich Shepard wrote:
> On Sat, 19 Jun 2021, MRAB wrote:
>
>> When it says "command line" it means the operating system's command line. If
>> it's the Python shell , it'll say "Python shell" or "Python prompt.
>
> MRAB,
>
> The root shell's (#) what I assumed. User shells (in bash, anyway) have $ as
> the prompt.
>
> Regardless,
>
> $ faker -o temp.out faker.names()
> -bash: syntax error near unexpected token `('
> [rshepard@salmo ~]$ faker -o temp.out faker.names
> Traceback (most recent call last):
> File "/usr/bin/faker", line 8, in <module>
> sys.exit(execute_from_command_line())
> File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 264, in execute_from_command_line
> command.execute()
> File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 246, in execute
> includes=arguments.include,
> File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 67, in print_doc
> provider_or_field], includes=includes)
> File "/usr/lib64/python3.7/site-packages/faker/proxy.py", line 63, in __init__
> **config)
> File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 56, in create
> prov_cls, lang_found = cls._get_provider_class(prov_name, locale)
> File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 68, in _get_provider_class
> provider_class = cls._find_provider_class(provider, locale)
> File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 90, in _find_provider_class
> provider_module = import_module(provider_path)
> File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
> File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
> File "<frozen importlib._bootstrap>", line 983, in _find_and_load
> File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
> ModuleNotFoundError: No module named 'faker.names'
> [rshepard@salmo ~]$
>
> It does not work from the bash command line as a user or as root.
>
>> The "root shell prompt (#)" suggests to me that it's Linux, so if you're
>> using Windows you'll need to use the equivalent for Windows.
>
> I don't do windows; defenestrated 24 years ago.
>
It looks like you're mixing some Python usage ("faker.names()") in with
command line usage.

Judging from the docs, I'd say you need something more like:

$ faker -o temp.out name

for 1 fake name or:

$ faker -r=10 -o temp.out name

for 10 fake names.
--
https://mail.python.org/mailman/listinfo/python-list